package com.edu.exam.entity.curriculum.course;

/**
 * 课程状态枚举
 * 所属模块：B-01 课程管理模块
 * 对应设计文档：B-01-01-02-子模块类图设计.md
 *
 * @author System
 * @version 1.0.0
 */
public enum CourseStatus {
    /**
     * 规划中
     */
    PLANNED("PLANNED", "规划中", "#999999"),

    /**
     * 开设中
     */
    ACTIVE("ACTIVE", "开设中", "#52c41a"),

    /**
     * 暂停
     */
    PAUSED("PAUSED", "暂停", "#faad14"),

    /**
     * 已结束
     */
    ENDED("ENDED", "已结束", "#1890ff"),

    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消", "#f5222d");

    private final String code;
    private final String statusName;
    private final String color;

    CourseStatus(String code, String statusName, String color) {
        this.code = code;
        this.statusName = statusName;
        this.color = color;
    }

    public String getCode() {
        return code;
    }

    public String getStatusName() {
        return statusName;
    }

    public String getColor() {
        return color;
    }

    /**
     * 根据代码获取枚举值
     */
    public static CourseStatus fromCode(String code) {
        for (CourseStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的课程状态代码: " + code);
    }

    /**
     * 根据状态名称获取枚举值
     */
    public static CourseStatus fromStatusName(String statusName) {
        for (CourseStatus status : values()) {
            if (status.getStatusName().equals(statusName)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的课程状态名称: " + statusName);
    }
}